import Vue from "vue";
import Vuex from 'vuex'
import Cookie from 'js-cookie'
Vue.use(Vuex)

const myvuex=new Vuex.Store({
    state:{
        token:'',//管理员登录
        teacher_no:'',//教师登录的工号
        teacher_name:'',//教师登录的姓名
    },
    mutations:{
       
        setToken(state,newtoken){
           state.token=newtoken
            Cookie.set("token",newtoken)
        },

        clearToken(state){
            state.token=''
            Cookie.remove('token')
        },
        getToken(state){
            state.token=state.token||Cookie.get('token')
        },
//=======================教师工号============================================
        setTeacherNo(state,t_no){
          state.teacher_no=t_no,
          Cookie.set('t_no',t_no)
        },
        getTeacherNo(state){
           state.teacher_no=state.teacher_no||Cookie.get('t_no')
        },
//=========================教师姓名===================================================  
       setTeacherName(state,t_name){
        state.teacher_name=t_name
        Cookie.set('t_name',t_name)
      }   ,
      getTeacherName(state){
        state.teacher_name=state.teacher_name||Cookie.get('t_name')
      }
    },

    actions:{},
    getters:{},
    modules:{}
})

export default myvuex
